package com.open.party.cloud.viewModel;

import cn.android.x.model.data.AppPageData
import cn.android.x.model.data.PageReq
import cn.android.x.model.data.ResultInfo
import com.alibaba.fastjson.JSON
import com.google.gson.JsonObject
import com.open.party.cloud.ServerConfig
import com.open.party.cloud.model.*
import com.open.party.cloud.model.data.Api
import com.sinothk.rxretrofit.RxRetrofit
import org.greenrobot.eventbus.EventBus
import rx.Subscriber
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers


class ExamineViewModel {

    // 党员教育 》 考试列表>>
    fun getPeiXunKaoShiListData(pageReq: PageReq<CommVo>) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getPeiXunKaoShiListData(pageReq)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<AppPageData<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<AppPageData<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getPeiXunKaoShiListData"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<AppPageData<ExamineBean>>) {
                    result.eventType = "getPeiXunKaoShiListData"
                    EventBus.getDefault().post(result)
                }
            })
    }

    // 我的》我的考试
    fun getExamineListData(pageReq: PageReq<CommVo>, flag: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getExamineListData(pageReq)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<AppPageData<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<AppPageData<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = flag
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<AppPageData<ExamineBean>>) {
                    result.eventType = flag
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun examineSignUp(vo: ExamineVo) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .examineSignUp(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ExamineSignBean>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ExamineSignBean>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "examineSignUp"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ExamineSignBean>) {
                    result.eventType = "examineSignUp"
                    EventBus.getDefault().post(result)
                }
            })
    }

    // 考试》提交考试答题答案
    fun submitExamineAnswer(vo: ExamineSubmitVo) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .submitExamineAnswer(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<String>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<String>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "submitExamineAnswer"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<String>) {
                    result.eventType = "submitExamineAnswer"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getMyClassList(pageReq: PageReq<CommVo>) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .myClassList
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<ExamineClassEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<ExamineClassEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getMyClassList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<ExamineClassEntity>>) {
                    result.eventType = "getMyClassList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getWzExaminationList(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getWzExaminationList(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getWzExaminationList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<ExamineBean>>) {
                    result.eventType = "getWzExaminationList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getExamineClassMemberPage(pageReq: PageReq<ExamineClassVO>) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getExamineClassMemberPage(pageReq)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<AppPageData<ExamineClassMemberEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<AppPageData<ExamineClassMemberEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getExamineClassMemberPage"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<AppPageData<ExamineClassMemberEntity>>) {
                    result.eventType = "getExamineClassMemberPage"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun doAttendance(attendanceVO: AttendanceVO) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .doAttendance(attendanceVO)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<AttendanceEntity>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<AttendanceEntity>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "doAttendance"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<AttendanceEntity>) {
                    result.eventType = "doAttendance"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getSchoolAttendanceList(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getSchoolAttendanceList(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<AttendanceEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<AttendanceEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getSchoolAttendanceList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<AttendanceEntity>>) {
                    result.eventType = "getSchoolAttendanceList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getExamineClassesAttendanceListForAll(pageReq: PageReq<ExamineClassVO>) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getExamineClassesAttendanceListForAll(pageReq)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<AppPageData<AttendanceEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<AppPageData<AttendanceEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getExamineClassesAttendanceListForAll"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<AppPageData<AttendanceEntity>>) {
                    result.eventType = "getExamineClassesAttendanceListForAll"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun examineClassJoin(vo: ExamineClassJoinVO) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .examineClassJoin(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<String>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<String>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "examineClassJoin"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<String>) {
                    result.eventType = "examineClassJoin"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun updateJoinClass(vo: ExamineClassJoinVO) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .updateJoinClass(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<String>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<String>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "updateJoinClass"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<String>) {
                    result.eventType = "updateJoinClass"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun insertStartExam(vo: ExamineClassJoinVO) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .insertStartExam(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<String>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<String>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "insertStartExam"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<String>) {
                    result.eventType = "insertStartExam"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getCourseTeacherList(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getCourseTeacherList(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<CourseTeacherEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<CourseTeacherEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getCourseTeacherList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<CourseTeacherEntity>>) {
                    result.eventType = "getCourseTeacherList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getSchoolCoursePage(pageReq: PageReq<ExamineClassVO>) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getSchoolCoursePage(pageReq)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<AppPageData<ExamineClassCourseEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<AppPageData<ExamineClassCourseEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getSchoolCoursePage"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<AppPageData<ExamineClassCourseEntity>>) {
                    result.eventType = "getSchoolCoursePage"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getTeacherEval(classId: String, userId: String, courseId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getTeacherEval(classId, userId, courseId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<TeacherRankEntity>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<TeacherRankEntity>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getTeacherEval"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<TeacherRankEntity>) {
                    result.eventType = "getTeacherEval"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun schoolTeacherEvalSave(teacherRankVO: TeacherRankVO) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .schoolTeacherEvalSave(teacherRankVO)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<TeacherRankEntity>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<TeacherRankEntity>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "schoolTeacherEvalSave"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<TeacherRankEntity>) {
                    result.eventType = "schoolTeacherEvalSave"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getSchoolCourseCourseList(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getSchoolCourseCourseList(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<ExamineAttendanceCourseEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<ExamineAttendanceCourseEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getSchoolCourseCourseList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<ExamineAttendanceCourseEntity>>) {
                    result.eventType = "getSchoolCourseCourseList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getSchoolClassesInfo(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getSchoolClassesInfo(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ExamineClassEntity>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ExamineClassEntity>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getSchoolClassesInfo"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ExamineClassEntity>) {
                    result.eventType = "getSchoolClassesInfo"
                    EventBus.getDefault().post(result)
                }
            })

    }

    fun getSimulationExamList() {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .simulationExamList
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ArrayList<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ArrayList<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getSimulationExamList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ArrayList<ExamineBean>>) {
                    result.eventType = "getSimulationExamList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getSimExamScore() {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .simExamScore
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ArrayList<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ArrayList<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getSimExamScore"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ArrayList<ExamineBean>>) {
                    result.eventType = "getSimExamScore"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getFormalExamList() {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getFormalExamList()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ArrayList<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ArrayList<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getFormalExamList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ArrayList<ExamineBean>>) {
                    result.eventType = "getFormalExamList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getFormalExamScore() {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .getFormalExamScore()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ArrayList<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ArrayList<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getFormalExamScore"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ArrayList<ExamineBean>>) {
                    result.eventType = "getFormalExamScore"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun insertExamUser(vo: ExamineGanBuRegisterVO) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .insertExamUser(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<String>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<String>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "insertExamUser"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<String>) {
                    result.eventType = "insertExamUser"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun schoolTeacherEvalGetXmEval(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .schoolTeacherEvalGetXmEval(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<SchoolXmEval>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<SchoolXmEval>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "schoolTeacherEvalGetXmEval"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<SchoolXmEval>) {
                    result.eventType = "schoolTeacherEvalGetXmEval"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun schoolTeacherEvalSaveXmEval(vo: SchoolXmEval) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .schoolTeacherEvalSaveXmEval(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<SchoolXmEval>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<SchoolXmEval>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "schoolTeacherEvalSaveXmEval"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<SchoolXmEval>) {
                    result.eventType = "schoolTeacherEvalSaveXmEval"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun schoolTeacherEvalGetBxEval(classId: String) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .schoolTeacherEvalGetBxEval(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<SchoolBxEval>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<SchoolBxEval>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "schoolTeacherEvalGetBxEval"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<SchoolBxEval>) {
                    result.eventType = "schoolTeacherEvalGetBxEval"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun schoolTeacherEvalSaveBxEval(vo: SchoolBxEval) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .schoolTeacherEvalSaveBxEval(vo)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<SchoolBxEval>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<SchoolBxEval>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "schoolTeacherEvalSaveBxEval"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<SchoolBxEval>) {
                    result.eventType = "schoolTeacherEvalSaveBxEval"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getClassExamineHistoryList() {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .classExamineHistoryList
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<ArrayList<ExamineBean>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<ArrayList<ExamineBean>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getClassExamineHistoryList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<ArrayList<ExamineBean>>) {
                    result.eventType = "getClassExamineHistoryList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun getJoinClassList() {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .joinClassList
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<ExamineClassEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<ExamineClassEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "getJoinClassList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<ExamineClassEntity>>) {
                    result.eventType = "getJoinClassList"
                    EventBus.getDefault().post(result)
                }
            })
    }

    fun schoolUserGetAuditList(classId: String?) {
        RxRetrofit.init(ServerConfig.SERVER_URL, ServerConfig.getHeader())
            .create(Api::class.java)
            .schoolUserGetAuditList(classId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(object : Subscriber<ResultInfo<List<ExamineClassMemberEntity>>>() {

                override fun onCompleted() {}

                override fun onError(e: Throwable) {
                    val result = ResultInfo<List<ExamineClassMemberEntity>>(ResultInfo.ERROR, ResultInfo.getErrorMsg(e.message))
                    result.eventType = "schoolUserGetAuditList"
                    EventBus.getDefault().post(result)
                }

                override fun onNext(result: ResultInfo<List<ExamineClassMemberEntity>>) {
                    result.eventType = "schoolUserGetAuditList"
                    EventBus.getDefault().post(result)
                }
            })
    }
}
